﻿@using SH = EMoney.IStock.Client.Framework.StringHelper;

@{
    string stocksCode = string.Empty;
    string selllist = string.Empty;
    }

<div class="rank_top">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="tbsorter">
        <tr>
            <th width="5%" align="center" valign="middle">@*<a  hidefocus="true" href="javascript:;" class="rank_right_a03"></a>*@序号</th>
            <th width="9%" align="center" valign="middle">名称</th>
            <th width="9%" align="center" valign="middle">@*<a  hidefocus="true" href="javascript:;" class="rank_right_a01"></a>*@代码</th>
            <th width="7%" align="center" valign="middle">最新</th>
            <th width="8%" align="center" valign="middle">涨幅</th>
            <th width="8%" align="center" valign="middle">持股数</th>
            <th width="8%" align="center" valign="middle">可卖数</th>
            <th width="7%" align="center" valign="middle">成本价</th>
            <th width="10%" align="center" valign="middle">持仓市值</th>
            <th width="9%" align="center" valign="middle">浮动盈亏</th>
            <th width="8%" align="center" valign="middle">盈亏比@*<a  hidefocus="true" href="javascript:;" class="rank_right_a02"></a>*@</th>
            <th width="12%" align="center" valign="middle">操作</th>
        </tr>
    </table>
</div>
<div class="rank_list" style="height:auto;">
    <div id="scrollBox1" class="scrollBox" scrollflag>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" id="tblist">
        @{
            if (ViewBag.Stocks != null && ViewBag.Stocks.data != null && ViewBag.Stocks.data.Count > 0)
            {
                int idx = 1;
                int stocknumber = 0;
                int sellnumber = 0;
                string stockcode = string.Empty;                
                
                foreach (EMoney.IStock.Client.Models.QQ.StocksData data in ViewBag.Stocks.data)
                {
                    stockcode = SH.FormatQQStockCode(data.stock_code);

                    stocksCode += stockcode + ",";
                    stocknumber = int.Parse(data.stock_count) + int.Parse(data.stock_count_today);
                    sellnumber = int.Parse(data.stock_count) - int.Parse(data.stock_count_freezed);
                    selllist += "{\"C\":\"" + stockcode + "\",\"N\":\"" + sellnumber + "\"},";
                    
                    <tr code="@stockcode">
                        <td width="5%" align="center" valign="middle">@idx</td>
                        <td width="9%" align="center" valign="middle"><span class="yellow stock" code="@stockcode">@data.stock_name</span></td>
                        <td width="9%" align="center" valign="middle">@stockcode</td>
                        <td width="7%" align="center" valign="middle">--</td>
                        <td width="8%" align="center" valign="middle">--%</td>
                        <td width="8%" align="center" valign="middle">@stocknumber</td>
                        <td width="8%" align="center" valign="middle">@sellnumber</td>
                        <td width="7%" align="center" valign="middle">@data.stock_cost</td>
                        <td width="10%" align="center" valign="middle">--</td>
                        <td width="9%" align="center" valign="middle">--</td>
                        <td width="8%" align="center" valign="middle">@data.yinkui</td>
                        <td width="12%" align="center" valign="middle"><a hidefocus="true" href="javascript:;" code="@SH.FormatQQStockCode(data.stock_code)" name="@data.stock_name" class="btn1 buy">加仓</a> <a  hidefocus="true" href="javascript:;" code="@SH.FormatQQStockCode(data.stock_code)" name="@data.stock_name" sellnumber="@sellnumber" class="btn2 sell">卖出</a></td>
                    </tr>
            idx++;
                }
                
                if(!string.IsNullOrEmpty(selllist))
                {
                    selllist = "[" + selllist.TrimEnd(',') + "]";
                }
            }
            else
            {
                <tr>
                    <td colspan="11" style="text-align:center;">--无记录--</td>
                </tr>
            }
        }
    </table>
    </div>
</div>
<input type="hidden" id="hidStocks" value="@stocksCode" />
<input type="hidden" id="hidSellList" value="@selllist" />
<script type="text/javascript">
    hidStocks = $("#hidStocks").val();
    hidSellList = $("#hidSellList").val();
    klinestocks = $("#hidStocks").val();
</script>